Repository navigation
feat(append): support write-buffer spill for append-only tables - #614
Merged
Merged
Conversation
SteNicholas
force-pushed
the
PAIMON-606
branch
2 times, most recently
from
December 2, 2026 15:22
810ac91 to
1558e63
Compare
zjw1111
reviewed
Dec 3, 2026
zjw1111
reviewed
Dec 3, 2026
SteNicholas
force-pushed
the
PAIMON-606
branch
from
December 3, 2026 17:36
1558e63 to
04185e9
Compare
SteNicholas
force-pushed
the
PAIMON-606
branch
4 times, most recently
from
December 4, 2026 07:24
7a8cc8a to
e64b790
Compare
zjw1111
reviewed
Dec 4, 2026
SteNicholas
force-pushed
the
PAIMON-606
branch
from
December 4, 2026 08:09
e64b790 to
4b6c5dd
Compare
Append-only writers sent every batch straight to a data file writer and reported no memory to the write memory manager, so many concurrent writers, e.g. a batch insert into many partitions, could run out of memory without any way to spill. - Add `write-buffer-for-append` and `write-max-writers-to-spill`, as in Paimon Java, defaulting to false and 10. - Add AppendWriteBuffer to keep written batches in memory, report the size of the Arrow buffers they reference to the write memory manager, spill them to temporary Arrow IPC files under memory pressure, with the threads set by SetWriteBufferSpillThreadNumber(), and replay them in write order on flush. - Let AppendOnlyWriter buffer batches with `write-buffer-for-append`, spilling only with `write-buffer-spillable` and a temporary directory, and flush data files instead when it cannot spill, its spill directory cannot be created, or its spill files reach `write-buffer-spill.max-disk-size`. - Once the active writers reach `write-max-writers-to-spill`, switch existing and future writers to spillable buffers before creating the next one, except for real-time writes, writes without a usable temporary directory, and writes with BLOBs in dedicated .blob files, which also bypass the write buffer. As in Paimon Java, a writer without a buffer closes its data files, reads their rows back into the new buffer ahead of later rows, and deletes the files, even if reading them back fails. - Count each batch read back toward the shared `write-buffer-size`, so the write memory manager spills or flushes the largest writers during the switch instead of letting every switched writer keep nearly `write-buffer-size` of rows. - Validate BLOB inline fields of buffered batches on write. - Keep the buffered rows and discard the partial data files of a failed replay, and track flushed data files before the buffer drops their rows, so a retry neither duplicates nor loses rows. - Fail a writer once rows it accepted can no longer be committed exactly once, e.g. when a spill fails or closing or reading back its data files fails during a switch, so later writes and commits return the error. - Delete spill files once their rows are flushed or the writer closes, retrying failed deletes, and on close delete the data files flushed but never returned by PrepareCommit(). - Add tests for AppendWriteBuffer, and extend the AppendOnlyWriter and AppendOnlyFileStoreWrite tests to cover spill and replay order, the shared `write-buffer-size`, the switch and its read-back, the spill disk budget, failures and cleanup. - Document the write buffer options, memory accounting, failure handling and cleanup in the append-only table user guide.
SteNicholas
force-pushed
the
PAIMON-606
branch
from
December 4, 2026 08:45
4b6c5dd to
91f519c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Linked issue: close #606
Support write buffers and spilling for append-only tables in Paimon C++, following Paimon Java's
write-buffer-for-appendandwrite-max-writers-to-spill. Append-only writers sent every batch straight to a data file writer and reported no memory to the write memory manager, so many concurrent writers, e.g. a batch insert into many partitions, could run out of memory without any way to spill.AppendWriteBufferthat reports the size of the Arrow buffers they reference to the write memory manager, spills them to temporary Arrow IPC files under memory pressure, written and read with the threads set byWriteContextBuilder::SetWriteBufferSpillThreadNumber(), and replays them in write order on flush.write-buffer-spill.max-disk-size.write-max-writers-to-spill, switch existing and future writers to spillable buffers before creating the next one. As in Paimon Java'stoBufferedWriter(), a writer without a buffer closes its data files, reads their rows back into the new buffer ahead of later rows, and deletes the files, even if reading them back fails. A writer that already has a buffer keeps its rows and starts spilling. Skip real-time writes, writes without a usable temporary directory, and writes with BLOBs in dedicated.blobfiles, which also bypass the write buffer; BLOB fields stored inline are buffered and can switch.write-buffer-size, so the write memory manager spills or flushes the largest writers during the switch instead of letting every switched writer keep nearlywrite-buffer-sizeof rows until the next write, much as Paimon Java's shared memory pool boundstoBufferedWriter().PrepareCommit().With dedicated VECTOR storage, the read-back can return one logical row as two partial rows, as in Paimon Java. A TODO in
AppendOnlyFileStoreWrite::CreateWriter()defers the fix until the Java one is merged, to keep both implementations aligned.Tests
AppendWriteBuffertests for in-memory buffering, enabling spill, spill and replay in write order with and without spill threads and with rows that are null at the top level, spill files of another schema, the disk budget, and cleanup of failed spills and on destruction.AppendOnlyWritertests for spill and replay on commit, memory accounting of imported slices, flushing when the buffer cannot spill or the disk budget is used up, and retries after failed replays, data file closes and compaction syncs, failed spills, BLOB inline field validation with a buffer, and cleanup on close.AppendOnlyWritertests for the switch to a spillable buffer: reusing an existing buffer, reading the rows already written back into the buffer and deleting their files, flushing them by spilling, by writing data files or through the memory check called after each batch read back, failing the writer and deleting the files when opening, reading or the memory check fails, and keeping direct writes without a reader.AppendOnlyFileStoreWritetests for switching at a custom and the default threshold, with and withoutwrite-buffer-for-appendand a usable temporary directory, across file formats and shared shredding, leaving only committed files, the write buffer size shared across buckets with and without spill threads and by the rows read back during a switch, BLOB fields, real-time writes and failed switches.CoreOptionstests for the defaults and parsing of the new options.API and Format
write-buffer-for-append, defaulting tofalse, andwrite-max-writers-to-spill, defaulting to10, and document thatwrite-buffer-sizeis shared by the write buffers of one write for append-only tables.FileStoreWrite::Write()that an I/O error may leave an append-only writer with write buffers unable to commit the rows it accepted, so the write must be recreated.Documentation
Yes.
docs/source/user_guide/append_only_table.rstcovers the options, memory accounting, spilling and its threads, the switch to spillable buffers and how it reads written rows back within the sharedwrite-buffer-size, its exclusions, cleanup and failure handling.Generative AI tooling
Generated-by: Claude Code (Claude Opus 5.5)
🤖 Generated with Claude Code